package com.bootdo.reptile;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author guoyunfei on 2021/12/5 3:11
 * @className WxImageUtil
 * @description TODO
 * @Version 1.0
 */
public class WxImageUtil {

    public static List<String> imgUrls(String urls){

        List<String> list = new ArrayList<>();
        try {
            String[] url = urls.split(",");

            int length = url.length;

            for (int i = 0; i < length; i++) {
                Document document = Jsoup.connect(url[i]).get();
                //Document document = Jsoup.connect("https://mp.weixin.qq.com/s/7XMETesLpNBvZ54FfElLGA").get();
                Document doc = Jsoup.parse(document.toString());
                Elements elements=doc.select("img");
                for (int j = 0; j < elements.size(); j++) {
                    System.out.println(elements.get(j).attr("data-src"));
                    list.add(elements.get(j).attr("data-src"));
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return list;
    }


}
